package com.lagou.edu.controller;

import com.lagou.edu.service.LoginService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/logout.do")
public class LogoutController {

    private final LoginService loginService;

    public LogoutController(LoginService loginService) {
        this.loginService = loginService;
    }

    @GetMapping
    public String login(HttpSession session) {
        loginService.logout(session);
        return "redirect:/login.do";
    }
}
